/**
 *  元素点击事件相关方法
 * */
export default {
	methods: {
		/**
		 * 链接跳转
		 */
		_event_link(eventData) {
			return new Promise((resolve) => {
				if (eventData.url) {
					window.location.href = eventData.url;
				}
				resolve()
			})
		},
		/**
		 * 分享
		 * @private
		 */
		_event_share() {
			return new Promise((resolve) => {
				window.alert('分享')
				resolve()
			})
		},
		/**
		 * 表单提交
		 * @private
		 */
		_event_submitForm() {
			return new Promise((resolve) => {
				window.alert('表单提交，待完善...')
				resolve()
			})
		},
		/**
		 * 天龙博弈启动浏览器打开
		 * @private
		 */
		_event_openBrowser(eventData) {
			return new Promise((resolve) => {
				if (eventData.url) {
					
					let url = eventData.url;
					let token = localStorage.getItem('token');
					
					if (token != null || token != '' || token != undefined) {
						if (eventData.url.includes("?")) {
							url = url + '&token=' + token;
						} else if (eventData.url.includes('&')) {
							url = url + '&token=' + token;
						} else {
							url = url + '?token=' + token;
						}
					}
					
					window.prompt(
						"",
						`up://["open_browser",${Date.now()},{"type":"promotion","url":"${url}","title":"${eventData.title}"}]`
					);
				}
				resolve()
			})
			
		},
		/**
		 * 天龙博弈弹出框
		 */
		_event_openDialog(eventData) {
			return new Promise((resolve) => {
				if (eventData.url) {
					let type = 1;
					window.prompt(
						"",
						`up://["open.web",${Date.now()},{"url":"${eventData.url}","title":"${eventData.title}","popuptype":${type}}]`
					);
				}
				resolve()
			})
			
		}
	}
}
